package com.ruoyi.common.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.entity.Mydone;
import com.ruoyi.common.service.IMydoneService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author dustball
 * @date 2021-04-23
 */
@RestController
@RequestMapping("/oa/mydone")
public class MydoneController extends BaseController
{
    @Autowired
    private IMydoneService mydoneService;

    /**
     * 查询VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('oa:mydone:list')")
    @GetMapping("/list")
    public TableDataInfo list(Mydone mydone)
    {
        startPage();
        List<Mydone> list = mydoneService.selectMydoneList(mydone);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('oa:mydone:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(Mydone mydone)
    {
        List<Mydone> list = mydoneService.selectMydoneList(mydone);
        ExcelUtil<Mydone> util = new ExcelUtil<Mydone>(Mydone.class);
        return util.exportExcel(list, "mydone");
    }

    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('oa:mydone:query')")
    @GetMapping(value = "/{filetype}")
    public AjaxResult getInfo(@PathVariable("filetype") String filetype)
    {
        return AjaxResult.success(mydoneService.selectMydoneById(filetype));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('oa:mydone:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Mydone mydone)
    {
        return toAjax(mydoneService.insertMydone(mydone));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('common:mydone:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Mydone mydone)
    {
        return toAjax(mydoneService.updateMydone(mydone));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('common:mydone:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
	@DeleteMapping("/{filetypes}")
    public AjaxResult remove(@PathVariable String[] filetypes)
    {
        return toAjax(mydoneService.deleteMydoneByIds(filetypes));
    }
}
